package com.yanwq.sayhi.widget;

import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

import com.yanwq.sayhi.R;
import com.yanwq.sayhi.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：yanweiqiang。
 * 日期：2016/6/17 0017。
 */
public class VideoPlayDialog extends BaseDialog {
    @BindView(R.id.video_view)
    VideoView mVvPlayback;

    String mPath;

    public VideoPlayDialog(Context context, String path) {
        super(context);
        mPath = path;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_video_play);
        ButterKnife.bind(this);

        mVvPlayback.setVideoPath(mPath);
        mVvPlayback.setKeepScreenOn(true);
        mVvPlayback.setMediaController(new MediaController(getContext()));
        mVvPlayback.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        mVvPlayback.start();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mVvPlayback.stopPlayback();
    }
}
